package com.itheima.filters;

import cn.hutool.core.util.StrUtil;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;

import java.io.IOException;

/**
 * @Author:篍
 * @Date: 2025/07/17 11:38
 * @Description:
 */
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    //tomcat反射调用自动创建
    public DemoFilter(){
        System.out.println("demoFilter构造器");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("你被DemoFilter拦住了");
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("你被DemoFilter拦住了");
    }

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("我被初始化了");
    }

    @Override
    public void destroy() {
        System.out.println("我去了");
    }
}
